package org.millioncall.yueyoga.admin.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.millioncall.openplatform.common.PaginatedList;
import org.millioncall.yueyoga.admin.dao.LiftClubDAO;
import org.millioncall.yueyoga.admin.model.AviatorExpression;
import org.millioncall.yueyoga.admin.model.HomePageLiftClub;
import org.millioncall.yueyoga.admin.model.LiftClub;
import org.millioncall.yueyoga.admin.model.LiftClubAdvance;
import org.millioncall.yueyoga.admin.model.LiftClubRecord;
import org.millioncall.yueyoga.admin.model.MemberClub;
import org.millioncall.yueyoga.admin.model.MemberLiftClub;
import org.millioncall.yueyoga.admin.service.LiftClubService;
import org.springframework.stereotype.Service;

@Service
public class LiftClubServiceImpl implements LiftClubService {
	
	private LiftClubDAO liftClubDAO;

	public LiftClubDAO getLiftClubDAO() {
		return liftClubDAO;
	}

	public void setLiftClubDAO(LiftClubDAO liftClubDAO) {
		this.liftClubDAO = liftClubDAO;
	}

	@Override
	public PaginatedList<LiftClub> findInPage(int start, int limit,
			String[] paramNames, String[] paramValues) {
		return this.liftClubDAO.findInPage(start, limit, paramNames,
				paramValues);
	}

	@Override
	public PaginatedList<LiftClub> findInPage(int start, int limit) {
		return this.liftClubDAO.findInPage(start, limit);
	}

	@Override
	public int deleteByIds(String[] ids) {
		int del = 0;
		if (ids == null || ids.length == 0) {
			throw new RuntimeException(" 未提交要删除活动的编号");
		} else {
			try {
				del = this.liftClubDAO.deleteByIds(ids);
				return del;
			} catch (Exception e) {
				return 0;
			}
		}
	}

	@Override
	public LiftClub findById(Integer id) {
		return this.liftClubDAO.findById(id);
	}

	@Override
	public int update(LiftClub liftClub) {
		return this.liftClubDAO.update(liftClub);
	}

	@Override
	public int save(LiftClub liftClub) {
		return this.liftClubDAO.save(liftClub);
	}

	@Override
	public PaginatedList<LiftClub> getIdInPage(int start, int limit,
			Map<String, Object> context) {
		return this.liftClubDAO.findPage(start, limit, context);
	}

	public boolean addLiftClub(Map<String, Object> map) {
		return liftClubDAO.addLiftClub(map) > 0;
	}

	public boolean updateLiftClub(Map<String, Object> map) {
		return liftClubDAO.updateLiftClub(map) > 0;
	}

	@Override
	public int deleteByLiftClubId(List<Integer> Ids) {
		return this.liftClubDAO.deleteByLiftClubId(Ids);
	}

	@Override
	public LiftClub selectById(Integer id) {
		if (id != null)
			return this.liftClubDAO.selectById(id);
		return null;
	}

	@Override
	public List<LiftClub> findLiftClubAll() {
		return liftClubDAO.findLiftClubAll();
	}

	@Override
	public List<MemberClub> findLiftClubId(Integer id) {
		return liftClubDAO.findLiftClubId(id);
	}

	@Override
	public PaginatedList<LiftClub> findLiftClubById(int start, int limit,
			Integer id) {
		return liftClubDAO.findLiftClubById(start, limit, id);
	}

	@Override
	public List<HomePageLiftClub> findLastLiftClubs(int n,String organizationId) {
		return this.liftClubDAO.findLastLiftClubs(n,organizationId);
	}

	@Override
	public PaginatedList<LiftClubRecord> findLiftClubsByCdts(int start,
			int limit, Map<String, Object> map) {
		
		return this.liftClubDAO.findLiftClubsByCdts(start, limit, map);
	}

	@Override
	public boolean addMemberToLiftClub(MemberLiftClub mem) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("memberId", mem.getMemberId());
		map.put("clubId", mem.getClubId());
		return this.liftClubDAO.addMemberToLiftClub(map);
	}

	@Override
	public MemberLiftClub findLiftClubMember(MemberLiftClub mem) {
		return this.liftClubDAO.findLiftClubMember(mem);
	}

	@Override
	public boolean deleteMemberFromLiftClub(MemberLiftClub mem) {
		return this.liftClubDAO.deleteMemberFromLiftClub(mem);
	}

	@Override
	public LiftClub findLiftClubByCdts(Map<String, Object> map) {
		return this.liftClubDAO.findLiftClubByCdts(map);
	}

	@Override
	public List<LiftClubAdvance> getAllLiftClubsWithAviator(
			Map<String, Object> params, AviatorExpression expression,
			Map<String, Object> aviatorParams, int limit) {
		return this.liftClubDAO.getAllLiftClubsWithAviator(params, expression, aviatorParams, limit);
	}
}
